package com.yanqu.road.logic.pb;

import com.yanqu.road.entity.player.UserHouseBar;
import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.pb.house.HouseProto;
import com.yanqu.road.utils.property.Property;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class HousePb {

    public static HouseProto.HouseTempMsg.Builder parseHouseTempMsg(int houseLv,int skinId){
        HouseProto.HouseTempMsg.Builder msg = HouseProto.HouseTempMsg.newBuilder();
        msg.setHouseLv(houseLv);
        msg.setSkinId(skinId);
        return msg;
    }

    public static HouseProto.HouseBarRewardTempMsg.Builder parseHouseBarRewardTempMsg(int pos,int patronsId,Property reward){
        HouseProto.HouseBarRewardTempMsg.Builder msg = HouseProto.HouseBarRewardTempMsg.newBuilder();
        msg.setPos(pos);
        msg.setReward1(reward.getCountByGoodsId(GameConfig.PATRONS_BAIYE_EXP_ID).longValue());
        msg.setReward2(reward.getCountByGoodsId(GameConfig.PATRONS_CHOUSUAN_EXP_ID).longValue());
        msg.setReward3(reward.getCountByGoodsId(GameConfig.GAME_ITEM_CREDIT).longValue());
        msg.setReward4(reward.getCountByGoodsId(GameConfig.GAME_ITEM_HOUSE_BANK_LUCK_ID).longValue());
        msg.setPatronsId(patronsId);
        return msg;
    }

    public static HouseProto.HouseBarInfoTempMsg.Builder parseHouseBarInfoTempMsg(UserHouseBar userHouseBar){
        HouseProto.HouseBarInfoTempMsg.Builder msg = HouseProto.HouseBarInfoTempMsg.newBuilder();
        msg.setPos(userHouseBar.getBarPos());
        msg.setPatronsId(userHouseBar.getPatronsId());
        msg.setDispatchTime(userHouseBar.getDispatchTime());
        msg.setSurplusTime(userHouseBar.getSurplusTime());
        msg.setToadSilver(Long.valueOf(userHouseBar.getToadSilver()));
        return msg;
    }

    public static Map<Integer, Integer> parseHouseDispatchTempMsg(HouseProto.HouseDispatchPatronsReqMsg reqMsg) {
        Map<Integer, Integer> res = new ConcurrentHashMap<>();
        for(HouseProto.HouseDispatchTempMsg tempMsg : reqMsg.getPatronsListList()){
            res.put(tempMsg.getPos(),tempMsg.getPatronsId());
        }
        return res;
    }
}
